import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import entity.Test;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

@Slf4j
public class TestJackson {
    public static void main(String[] args) throws JsonProcessingException {
        Test test1 = new Test();
        List<Integer> list1 = new LinkedList<>();
        list1.add(1);
        list1.add(2);
        list1.add(3);
        test1.setList(list1);

        Test test2 = new Test();
        List<Integer> list2 = new ArrayList<>();
        list2.add(3);
        list2.add(2);
        list2.add(1);
        test2.setList(list2);

        log.info("test1 List Type:{}", test1.getList().getClass());
        log.info("test2 List Type:{}", test2.getList().getClass());

        ObjectMapper om = new ObjectMapper();

        String json1 = om.writeValueAsString(test1);
        String json2 = om.writeValueAsString(test2);
        log.info("test1:{}", json1);
        log.info("test2:{}", json2);

        Test sTest1 = om.readValue(json1, Test.class);
        Test sTest2 = om.readValue(json2, Test.class);
        log.info("sTest1 List Type:{}", sTest1.getList().getClass());
        log.info("sTest2 List Type:{}", sTest2.getList().getClass());
    }
}
